package com.example.utils;

import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

@Component
public class DateUtil {
    /**
     * 判断时间是不是今天
     * @param date
     * @return    是返回true，不是返回false
     */
    private static boolean isNow(Date date) {
        //当前时间
        Date now = new Date();
        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
        //获取今天的日期
        String nowDay = sf.format(now);
        //对比的时间
        String day = sf.format(date);
        return day.equals(nowDay);



    }

    // 获取每一天的23:55的毫秒数
    public static Long getEveryDayTime() {
        Calendar calendar = Calendar.getInstance();
        calendar .set(Calendar.HOUR_OF_DAY, 23);
        calendar .set(Calendar.MINUTE, 55);
        calendar .set(Calendar.SECOND, 0);
        return calendar .getTimeInMillis();
    }
}
